package cn.rkylin.oms.order.adapter;

import cn.rkylin.oms.system.shop.vo.ShopVO;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @Author: jipengcheng
 * @Created: 2018-2-27
 */
@Service("vipOrderAdapter")
public class VipOrderAdapter extends  OrderAdapter{


    @Override
    public int download(String shopId, String dateTimeStart, String dateTimeEnd) throws Exception {
        return 0;
    }

    @Override
    public int download(Map<String, String> map) throws Exception {
        return 0;
    }

    /**
     * 平台发货
     * @param shopId
     *            店铺id
     * @param dateTimeStart
     *            开始时间
     * @param dateTimeEnd
     *            结束时间 return 结果数量
     * @return
     * @throws Exception
     */
    @Override
    public Map<String, Object> consign(String shopId, String dateTimeStart, String dateTimeEnd) throws Exception {

        Map<String, Object> returnMap = new HashMap<String, Object>();
        Map<String, Object> paramMap = new HashMap<String, Object>();

        ShopVO shopVO = getShop(shopId);
        // shop取得失败的时候，返回
        if (shopVO == null) {
            returnMap.put("success", "false");
            returnMap.put("msg", "shopVO is null");
            return returnMap;
        }
        // 如果未开启自动平台发货开关
        if ("n".equals(shopVO.getIsAutoPlatformDelivery())) {
            returnMap.put("success", "false");
            returnMap.put("msg", "未开启自动平台发货开关");
            return returnMap;
        }
        paramMap.put("shop", shopVO);

        long startTime = System.currentTimeMillis();
        returnMap = this.getOrderVisitor().consign(paramMap);
        //logger.error(">>>>>>>>>>>> 平台发货:" + (System.currentTimeMillis() - startTime) + "<<<<<<<<<<<");
        return returnMap;
    }
}
